package com.haierp.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.framework.service.impl.SuperServiceImpl;
import com.haierp.mapper.SellerMapper;
import com.haierp.mapper.SellerTypeMapper;
import com.haierp.model.SellerType;
import com.haierp.service.ISellerTypeService;
import com.haierp.util.JsonPageResult;
import com.haierp.vo.SellerTypeQueryVO;

/**
 * 
 * Title: SellerTypeServiceImpl.java
 * Description: Implements ISellerTypeService
 *
 * @author jc
 * Mar 17, 2017
 *
 */

@Service("sellerTypeService")
public class SellerTypeServiceImpl extends SuperServiceImpl<SellerTypeMapper, SellerType> implements ISellerTypeService {
	
	@Autowired
	private SellerTypeMapper sellerTypeMapper;
	
	@Override
	public Integer querySellerTypesCount(SellerTypeQueryVO sellerTypeQueryVO)
	{
		return sellerTypeMapper.querySellerTypesCount(sellerTypeQueryVO);
	}
	
	@Override
	public JsonPageResult<List<SellerType>> querySellerTypeList(SellerTypeQueryVO sellerTypeQueryVO) {
		JsonPageResult<List<SellerType>> sellerTypeResult = new JsonPageResult<>();
		
		Integer totalCount = sellerTypeMapper.querySellerTypesCount(sellerTypeQueryVO);
		
		if ((null != totalCount) && (0L != totalCount)) {
			sellerTypeResult.buildPage(totalCount, sellerTypeQueryVO);
			
			List<SellerType> sellerTypes = sellerTypeMapper.querySellerTypes(sellerTypeQueryVO);
			sellerTypeResult.setData(sellerTypes);			
		} else {
			List<SellerType> sellerTypes = new ArrayList<>();
			sellerTypeResult.setData(sellerTypes);
		}
		
		return sellerTypeResult;
	}

}
